﻿using Microsoft.AspNetCore.Idenmpotency;

namespace Yarp.ReverseProxy.Idenmptency.Test
{
    /// <summary>
    /// 幂等性请求生成器：个性化的生成幂等性请求
    /// </summary>
    public class AppIdenmpotencyRequestGenerator : IYarpIdenmpotencyRequestGenerator
    {
        /// <summary>
        /// 个性化的生成幂等性请求
        /// </summary>
        /// <param name="context"></param>
        /// <param name="next"></param>
        /// <returns></returns>
        public YarpIdenmpotencyRequest Generate(HttpContext context ,RequestDelegate next)
        {
            var key = context.Request.Headers["IdenmpotencyKey"];
            return new YarpIdenmpotencyRequest(context, next, key.ToString());
        }
    }
}
